const fs = require('fs-extra')
const yaml = require('js-yaml')

let customizedConfig = (function () {
  if (fs.existsSync('config/config.yaml')) {
    let fileContent = fs.readFileSync('config/config.yaml', 'utf8')
    return yaml.safeLoad(fileContent)
  } else {
    return {}
  }
})()

let defaultConfig = {
  logger: {
    level: 'info'
  }
}

const serverConfig = Object.assign({}, defaultConfig, customizedConfig)

module.exports = serverConfig
